package com.jeesite.modules.ocr.utils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;

import org.springframework.web.multipart.MultipartFile;

import com.jeesite.common.io.FileUtils;
import com.jeesite.modules.file.utils.FileUploadUtils;
import com.jeesite.modules.ocr.base.IOcrBaseInterface;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;


/**
 * 华为 OCR 调用样例集 文档详见：22-人工智能套件(AIKits) 8.3.1 API参考(for 华为云Stack 8.3.1) 01.pdf
 * 
 * @author 姚海陆,长春叭哥
 * @version 2024-07-28
 */
public class AIKitsOCRDemoUtils implements IOcrBaseInterface {

	public static final String API_HOST = "http://ip:port/";

	public static String getAuthorizationToken() {
		// 利用缓存定时更新获取值
		return "MIIEiwYJKoZIhvcNAQcCoIIEfDCCBHgCAQExDTALBglghkgBZQMEAgEwggLsBgkqhkiG9w0BBwGgggLdBIIC2XsidG9rZW4iOnsiZXhwaXJlc19hdCI6IjIwMjQtMDctMTJUMDY6NTU6MTguNDQyMDAwWiIsIm1ldGhvZHMiOlsicGFzc3dvcmQiXSwiY2F0YWxvZyI6W10sInJvbGVzIjpbeyJuYW1lIjoidGFnX2FkbSIsImlkIjoiYTY0OGNmYmNkZmMzNDJiODg0MWU3NWFjNGI2YWVlNzMifSx7Im5hbWUiOiJ2ZGNfYWRtIiwiaWQiOiJhNjU2ODdjZjdjYzY0MDNjODczODRjMDgyNTAwZWMyZSJ9LHsibmFtZSI6InRlX2FkbWluIiwiaWQiOiJlY2FmODhmMzE0NzM0YTY5YjJmMzM5MjBhNGUxZGRjNCJ9LHsibmFtZSI6InZkY19vd25lciIsImlkIjoiY2ZhNDE0MzQxM2QzNDAyNjk1ZTU1OGM5NmFiYjI5ZWMifSx7Im5hbWUiOiJhcHByb3ZfYWRtIiwiaWQiOiIxNDViM2VmMDBlOTI0ZTczYTZmNjcwMTk4YmRlMzUzNyJ9XSwicHJvamVjdCI6eyJkb21haW4iOnsibmFtZSI6Imd3bGxtIiwiaWQiOiJlYWEwNjcyNGNlNmI0YTNjOTkwOTY4YTI2YjUxMWJiMCJ9LCJuYW1lIjoiZ3cteHV6aG91LTJfcGFuZ3VsYXJnZW1vZGVscyIsImlkIjoiMDYxMTY0M2JjNmFhNGQ2ODhlMDFiNGMxNTFhNGFkNTUifSwiaXNzdWVkX2F0IjoiMjAyNC0wNy0xMVQwNjo1NToxOC40NDIwMDBaIiwidXNlciI6eyJkb21haW4iOnsibmFtZSI6Imd3bGxtIiwiaWQiOiJlYWEwNjcyNGNlNmI0YTNjOTkwOTY4YTI2YjUxMWJiMCJ9LCJuYW1lIjoiZ3dsbG0iLCJpZCI6IjBhZDM4YjJlMmYzYzQzNzk5MmUyYTEwMWMzZTM3ZWMxIn19fTGCAXIwggFuAgEBMEkwPTELMAkGA1UEBhMCQ04xDzANBgNVBAoTBkh1YXdlaTEdMBsGA1UEAxMUSHVhd2VpIElUIFByb2R1Y3QgQ0ECCBWpkSG6QZq3MAsGCWCGSAFlAwQCATANBgkqhkiG9w0BAQEFAASCAQCU";
	}

	/**
	 * 通用ocr识别验证（该接口需要登录管网vpn） http://ip:port/v2/123/ocr/general-text
	 * 
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {

		recognizeGeneralText("123");

	}

	/**
	 * 通用表格识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeGeneralTable(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/general-table")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * RecognizeVatInvoice 增值税发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeVatInvoice(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/vat-invoice")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 发票验真
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeInvoiceVerification(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/invoice-verification")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	public static String convertImageToBase64(String imagePath) {
		byte[] imageBytes = null;
		try {
			// 读取图片文件
			imageBytes = Files.readAllBytes(Paths.get(imagePath));
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

		// 将字节数组转换为 Base64 编码的字符串
		String base64Image = Base64.getEncoder().encodeToString(imageBytes);
		return base64Image;
	}
	

	public static String convertImageToBase64(MultipartFile file) {
		byte[] imageBytes = null;
		try {
			// 读取图片文件
			imageBytes = file.getBytes();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

		// 将字节数组转换为 Base64 编码的字符串
		String base64Image = Base64.getEncoder().encodeToString(imageBytes);
		return base64Image;
	}

	/**
	 * 通用文字识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeGeneralText(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		String base64 = convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\02.jpg");
		String json = "{\"image\":\"" + base64 + "\",  \"detect_direction\":false,  \"quick_mode\":false }";
		MediaType mediaType = MediaType.get("application/json; charset=utf-8");
		RequestBody body = RequestBody.create(mediaType, json);
		Request request = new Request.Builder().url(API_HOST + "v2/123/ocr/general-text").method("POST", body)
				.addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("User-Agent", "Apifox/1.0.0 (https://apifox.com)")
				.addHeader("Content-Type", "application/json").addHeader("Accept", "*/*")
				.addHeader("Host", "ip:port").addHeader("Connection", "keep-alive").build();

		// 发送请求并处理响应
		Response response = null;
		try {
			response = client.newCall(request).execute();
			if (!response.isSuccessful())
				throw new IOException("Unexpected code " + response);
			// 处理响应
			System.out.println(response.body().string());
			return response;
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (response != null) {
				response.body().close();
			}
		}
		return response;
	}

	/**
	 * 网络图片识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeWebImage(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/web-image")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 智能文档解析
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeSmartDocumentRecognizer(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/smart-document-recognizer")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 防疫健康码识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeHealthCode(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/health-code")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 定额发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeQuotaInvoice(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/quota-invoice")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 身份证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeIdCard(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/id-card").method("POST", body)
				.addHeader("X-Auth-Token", getAuthorizationToken()).build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 手写文字识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeHandwriting(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/handwriting")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 印章识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeSeal(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/seal").method("POST", body)
				.addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 行驶证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeVehicleLicense(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/vehicle-license")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 道路运输证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeTransportationLicense(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/transportation-license")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 出租车发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeTaxiInvoice(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/taxi-invoice")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 智能分类识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeAutoClassification(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/auto-classification")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 车辆通行费发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeTollInvoice(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/toll-invoice")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 机动车销售发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeMvsInvoice(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/mvs-invoice")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 车牌识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeLicensePlate(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/general-table")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 飞机行程单识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeFlightItinerary(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/flight-itinerary")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 营业执照识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeBusinessLicense(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/business-license")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 驾驶证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeDriverLicense(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/driver-license")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 名片识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeBusinessCard(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/business-card")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 火车票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeTrainTicket(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/train-ticket")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * VIN码识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeVin(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/general-table")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 护照识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizePassport(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/passport")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 银行卡识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeBankcard(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/general-table")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 保险单识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeInsurancePolicy(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/insurance-policy")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 财务报表识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeFinancialStatement(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/financial-statement")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 道路运输从业资格证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeQualificationCertificate(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder()
				.url(API_HOST + "v2/" + project_id + "/ocr/transportation-qualification-certificate")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 电子面单识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeWaybillElectronic(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/waybill-electronic")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 核酸检测记录识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizePcrTestRecord(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/pcr-test-record")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 自定义模板OCR
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeCustomTemplate(String project_id) throws IOException {

		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{\"classifier_mode\":true}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/custom-template")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 泰文身份证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeThailandIdcard(String project_id) throws IOException {

		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/thailand-id-card")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 泰国车牌识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeThailandLicensePlate(String project_id) throws IOException {

		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/thailand-license-plate")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 车辆合格证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeVehicleCertificate(String project_id) throws IOException {

		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/vehicle-certificate")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 承兑汇票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeAcceptanceBill(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/acceptance-bill")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 不动产证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeRealEstateCertificate(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/real-estate-certificate")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 哥伦比亚身份证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeColombiaIdCard(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/colombia-id-card")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 户口本识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeHouseholdRegister(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/household-register")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

	/**
	 * 银行回单识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public static Response recognizeBankReceipt(String project_id) throws IOException {
		OkHttpClient client = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		RequestBody body = RequestBody.create(mediaType, "{}");
		Request request = new Request.Builder().url(API_HOST + "v2/" + project_id + "/ocr/bank-receipt")
				.method("POST", body).addHeader("X-Auth-Token", getAuthorizationToken())
				.addHeader("Content-Type", "application/json;charset=UTF-8").build();
		Response response = client.newCall(request).execute();
		return response;
	}

}
